//package com.lagou.service.impl;
//
//import com.lagou.service.IRocketService;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.client.producer.SendCallback;
//import org.apache.rocketmq.client.producer.SendResult;
//import org.apache.rocketmq.spring.core.RocketMQTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.messaging.Message;
//import org.springframework.messaging.support.GenericMessage;
//import org.springframework.stereotype.Service;
//
//@Service
//@Slf4j
//public class RocketServiceImpl implements IRocketService {
//
//    @Autowired
//    private RocketMQTemplate rocketMQTemplate;
//
//    @Override
//    public SendResult syncSend(String id) {
//        Message<String> message = new GenericMessage<String>(id);
//        final SendResult result = rocketMQTemplate.syncSend("tp_demo_seckill", message);
//        log.info("result:{}", result);
//        return result;
//    }
//
//    @Override
//    public void asyncSend() {
//        // 异步消息
//        Message<String> message = new GenericMessage<String>("test_producer" );
//        rocketMQTemplate.asyncSend("test_producer", message, new SendCallback() {
//            @Override
//            public void onSuccess(SendResult sendResult) {
//                System.out.println(sendResult);
//            }
//            @Override
//            public void onException(Throwable e) {
//                System.out.println("发送失败");
//            }
//        });
//    }
//}
